package com.atguigu.daijia.common.util;

import jakarta.servlet.http.HttpServletRequest;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class RequestUtils {
    public static String readData(HttpServletRequest request){
        StringBuilder requestBody = new StringBuilder();
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(request.getInputStream()))) {
            String line;
            while ((line = reader.readLine()) != null) {
                requestBody.append(line);
            }
        }catch (IOException e) {
            e.printStackTrace();
        }
        return requestBody.toString();
    }
} 